<template>
	<view>
		<view class="banner-back" v-if="bannerList">
			<swiper class="swiper" circular :indicator-dots="true" :autoplay="true" :interval="3000" :duration="500"
				indicator-color="#666" indicator-active-color="#fff">
				<swiper-item v-for="(item,index) in bannerList" @click="bannerAction(item)">
					<image class="banner-image" :src="item.image"></image>
				</swiper-item>
			</swiper>
		</view>
		<view class="main-view" v-if="menuList">
			<view class="menu-back">
				<view class="menu-item" v-for="(item,index) in menuList" @click="menuAction(item)">
					<view>
						<image :src="item.image"></image>
						<view class="menu-text">{{item.name}}</view>
					</view>
				</view>
				<view style="height: 0;width: 20%;" v-for="(item,index) in 5"></view>
			</view>
			<view class="goods-back" v-if="goodsList">
				<view class="goods-item" v-for="(goods,index) in goodsList" @click="goodsAction(goods)">
					<view class="goods-image-back">
						<image class="goods-image" mode="heightFix" :src="goods.image"></image>
					</view>
					<view class="goods-name">{{goods.title}}</view>
					<view class="stock-back">
						<view>库存：{{goods.stock}}</view>
						<view>销量：{{goods.sales}}</view>
					</view>
					<view class="price-back">
						<view class="line-price-text">¥{{goods.line_price}}</view>
						<view class="price-text">¥{{goods.price}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		name: "wts-storeIndex",
		props: {
			bannerList: '',
			menuList: '',
			goodsList: ''
		},
		data() {
			return {

			};
		},
		watch: {

		},
		methods: {
			// 点击轮播图
			bannerAction(item) {
				this.$emit('bannerAction', item)
			},
			// 点击金刚区
			menuAction(item) {
				this.$emit('menuAction', item)
			},
			// 点击商品
			goodsAction(goods) {
				this.$emit('goodsDetail', goods)
			}
		}
	}
</script>
<style lang="scss">
	page {
		background-color: #f5f5f5;
	}

	.banner-back {
		.swiper {
			height: 360rpx;
		}

		.banner-image {
			width: 100%;
			height: 100%;
		}
	}

	.main-view {
		padding: 0 20rpx;
	}

	.menu-back {
		background-color: #fff;
		padding-top: 30rpx;
		border-radius: 10rpx;
		margin-top: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;

		.menu-item {
			width: 20%;
			display: flex;
			flex-direction: column;
			align-items: center;
			margin-bottom: 30rpx;

			image {
				width: 80rpx;
				height: 80rpx;
			}

			.menu-text {
				font-size: 28rpx;
				line-height: 28rpx;
				text-align: center;
				margin-top: 10rpx;
			}
		}
	}

	.goods-back {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		margin-top: 20rpx;

		.goods-item {
			background-color: #fff;
			border-radius: 10rpx;
			width: calc(50vw - 30rpx);
			margin-bottom: 20rpx;
			padding-bottom: 30rpx;

			.goods-image-back {
				display: flex;
				align-items: center;
				justify-content: center;

				.goods-image {
					width: 100%;
					height: calc(50vw - 30rpx);
					border-radius: 10rpx 10rpx 0 0;
				}
			}

			.goods-name {
				font-size: 28rpx;
				line-height: 40rpx;
				font-weight: bold;
				-webkit-line-clamp: 2;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				overflow: hidden;
				text-overflow: ellipsis;
				padding: 0 20rpx;
				margin-top: 10rpx;
				height: 80rpx;
			}

			.stock-back {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 20rpx;
				font-size: 26rpx;
				color: #999;
				margin-top: 10rpx;
			}

			.price-back {
				display: flex;
				align-items: flex-end;
				padding: 20rpx 20rpx 0 20rpx;
				height: 35rpx;

				.price-text {
					color: #a20000;
					font-size: 34rpx;
					font-weight: bold;
				}

				.line-price-text {
					color: #999;
					font-size: 26rpx;
					text-decoration: line-through;
				}
			}
		}
	}
</style>